<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Sparrow.Chart">
    
    <local:BorderThicknessToLeftAndRightConverter x:Key="borderThicknessConverterXAxis"/>
    <local:BorderThicknessToTopBottomConverter x:Key="borderthicknessConverterYAxis"/>
    <!-- SparrowChart Default Style -->
    <Style TargetType="local:SparrowChart">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:SparrowChart">
                    <Border Background="{Binding Background,RelativeSource={RelativeSource TemplatedParent}}"
                            BorderBrush="{Binding BorderBrush,RelativeSource={RelativeSource TemplatedParent}}"
                            BorderThickness="{Binding BorderThickness,RelativeSource={RelativeSource TemplatedParent}}">
                        <local:RootPanel x:Name="Part_rootDockPanel" LegendDock="{Binding Legend.Dock,RelativeSource={RelativeSource TemplatedParent}}">
                            <Grid x:Name="Part_OuterChartPanel">
                                <!--<ContentPresenter VerticalAlignment="{Binding Legend.VerticalAlignment,RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="{Binding Legend.HorizontalAlignment,RelativeSource={RelativeSource TemplatedParent}}"   Content="{Binding Legend,RelativeSource={RelativeSource TemplatedParent}}" />-->
                            </Grid>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Border x:Name="PART_containerBorder" Grid.Row="1" Grid.Column="1" Style="{Binding ContainerBorderStyle,RelativeSource={RelativeSource TemplatedParent}}" >
                                    <Grid x:Name="Part_InnerChartPanel">
                                        <local:ContainerCollection x:Name="PART_containers" RenderingMode="{Binding RenderingMode,RelativeSource={RelativeSource TemplatedParent}}" Series="{Binding Series,RelativeSource={RelativeSource TemplatedParent}}"  XAxis="{Binding XAxis,RelativeSource={RelativeSource TemplatedParent}}" YAxis="{Binding YAxis,RelativeSource={RelativeSource TemplatedParent}}"/>
                                    </Grid>
                                </Border>
                                <local:AxesPanel Grid.Row="0" Grid.Column="1" x:Name="PART_TopAxes"/>
                                <local:AxesPanel Grid.Row="1" Grid.Column="0" x:Name="PART_LeftAxes"/>
                                <local:AxesPanel Grid.Row="1" Grid.Column="2" x:Name="PART_RightAxes"/>
                                <local:AxesPanel Grid.Row="2" Grid.Column="1" x:Name="PART_BottomAxes"/>
                                <ContentPresenter Margin="{Binding BorderThickness,ElementName=PART_containerBorder,Converter={StaticResource borderthicknessConverterYAxis}}"  Width="{Binding AxisWidth,RelativeSource={RelativeSource TemplatedParent}}"   Visibility="{Binding YAxis.Visibility,RelativeSource={RelativeSource TemplatedParent}}" Content="{Binding YAxis,RelativeSource={RelativeSource TemplatedParent}}" Grid.Row="1" Grid.Column="0"  x:Name="PART_yAxis"/>
                                <ContentPresenter Margin="{Binding BorderThickness,ElementName=PART_containerBorder,Converter={StaticResource borderThicknessConverterXAxis}}"  Height="{Binding AxisHeight,RelativeSource={RelativeSource TemplatedParent}}" Visibility="{Binding XAxis.Visibility,RelativeSource={RelativeSource TemplatedParent}}" Content="{Binding XAxis,RelativeSource={RelativeSource TemplatedParent}}" Grid.Row="2" Grid.Column="1"  x:Name="PART_xAxis"/>
                            </Grid>
                        </local:RootPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <local:BooleanToVisibilityConverter x:Key="booleanToVisibility"/>
    <Style TargetType="local:Legend">
        <Setter Property="Padding" Value="6"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:Legend">
                    <Border BorderBrush="{TemplateBinding BorderBrush}"
                     BorderThickness="{TemplateBinding BorderThickness}"
                     CornerRadius="{TemplateBinding CornerRadius}"
                     Padding="{TemplateBinding Padding}"
                     Background="{TemplateBinding Background}">
                        <StackPanel Orientation="Vertical" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                            <ContentPresenter Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}"/>
                            <ItemsPresenter/>
                        </StackPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="HorizontalAlignment" Value="Center"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
